package leetcode.code1465;

import java.util.Arrays;

public class Solution {

	int mod = (int) 1e9 + 7;

	public int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {
		Arrays.sort(horizontalCuts);
		Arrays.sort(verticalCuts);
		long mh = 0, last = 0;
		for (int i = 0; i < horizontalCuts.length; i++) {
			mh = Math.max(mh, horizontalCuts[i] - last);
			last = horizontalCuts[i];
		}
		mh = Math.max(mh, h - last);
		long mw = 0;
		last = 0;
		for (int i = 0; i < verticalCuts.length; i++) {
			mw = Math.max(mw, verticalCuts[i] - last);
			last = verticalCuts[i];
		}
		mw = Math.max(mw, w - last);
		return (int) (mw * mh % mod);
	}
}
